//
// Created by 先通明 on 2018/8/18.
//

#include "pe12-3a.h"
//
// Created by 先通明 on 2018/8/17.
//

#include <stdio.h>
#include "pe12-3a.h"


void calculate(int mod) {
    int mode;//模式
    double distance;//距离
    double fuel;//燃料
    if (mod > -1 && mod < 2) {
        mode = mod;
    } else {
        puts("Invalid mode specified. Mode 1( US) used.");
        mode = 1;
    }
    if (mode == 1) {
        printf("Enter distance traveled in miles:");
        scanf("%lf", &distance);
        printf("Enter fuel consumed in gallons:");
        scanf("%lf", &fuel);
        printf("Fuel consumption is %.2f mile per gallon.",  distance / fuel);
    } else {
        printf("Enter distance traveled in kilometers:");
        scanf("%lf", &distance);
        printf("Enter fuel consumed in liters:");
        scanf("%lf", &fuel);
        printf("Fuel consumption is %.2f liters per 100 km.\n", fuel / distance * 100);
    }

}